﻿using UnityEngine;

namespace UFrame
{
    /// <summary>
    /// 层级
    /// </summary>
    public class DefineLayerMask
    {
        public static string Terrain = "Terrain";
        public static string Effect = "Effect";
        public static string Player = "Player";
        public static string Construction = "Construction";
        public static string Obstacle = "Obstacle";
        public static string MouseNoClick = "MouseNoClick";
        public static string Entity = "Entity";


        public static int IntTerrain;
        public static int IntEffect;
        public static int IntPlayer;
        public static int IntConstruction;
        public static int IntObstacle;
        public static int IntMouseNoClick;
        public static int IntEntity;


        static DefineLayerMask()
        {
            IntTerrain = LayerMask.NameToLayer(Terrain);
            IntEffect = LayerMask.NameToLayer(Effect);
            IntPlayer = LayerMask.NameToLayer(Player);
            IntConstruction = LayerMask.NameToLayer(Construction);
            IntObstacle = LayerMask.NameToLayer(Obstacle);
            IntMouseNoClick = LayerMask.NameToLayer(MouseNoClick);
            IntEntity = LayerMask.NameToLayer(Entity);
        }


        public static int PlayerTerrainConstruction
        {
            get
            {
                int layer = 1 << LayerMask.NameToLayer("Player") |
                            1 << LayerMask.NameToLayer("Terrain") |
                            1 << LayerMask.NameToLayer("Construction");

                return layer;
            }
        }

        public static int PlayerTerrainConstructionUIEntity
        {
            get
            {
                int layer = 1 << LayerMask.NameToLayer("Player") |
                            1 << LayerMask.NameToLayer("Terrain") |
                            1 << LayerMask.NameToLayer("Construction") |
                            1 << LayerMask.NameToLayer("UI") |
                            1 << LayerMask.NameToLayer("Entity");

                return layer;
            }
        }

        public static int ConstructionObstacle
        {
            get
            {
                int layer = 1 << LayerMask.NameToLayer(DefineLayerMask.Terrain) |
                            1 << LayerMask.NameToLayer(DefineLayerMask.Construction);

                return layer;
            }
        }

        public static int EffectPlayer
        {
            get
            {
                int layer = 1 << LayerMask.NameToLayer(DefineLayerMask.Effect) |
                            1 << LayerMask.NameToLayer(DefineLayerMask.Player);

                return layer;
            }
        }

        /*    public static int IntTerrain
            {
                get { return LayerMask.NameToLayer(Terrain); }
            }

            public static int IntEffect
            {
                get { return LayerMask.NameToLayer(Effect); }
            }

            public static int IntConstruction
            {
                get { return LayerMask.NameToLayer(Construction); }
            }

            public static int IntObstacle
            {
                get { return LayerMask.NameToLayer(Obstacle); }
            }

            public static int IntPlayer
            {
                get { return LayerMask.NameToLayer(Player); }
            }

            public static int IntMouseNoClick
            {
                get { return LayerMask.NameToLayer(MouseNoClick); }
            }*/
    }


    /// <summary>
    /// 渲染的层级
    /// </summary>
    public class DefineSortLayer
    {
        public static string Terrain = "Terrain";
        public static string Entity = "Entity";
        public static string Effect = "Effect";

        private static int entitySortingId = 0;
        private static int terrainSortingId = 0;
        private static int effectSortingId = 0;

        public static int IntEntity;
        public static int IntTerrain;
        public static int IntEffect;

        static DefineSortLayer()
        {
            IntEntity = SortingLayer.NameToID(Entity);
            IntTerrain = SortingLayer.NameToID(Terrain);
            IntEffect = SortingLayer.NameToID(Effect);
        }


        public static int EntitySortingId
        {
            get { return ++entitySortingId; }
        }


        public static int TerrainSortingId
        {
            get { return ++terrainSortingId; }
        }


        public static int EffectSortingId
        {
            get { return ++effectSortingId; }
        }
    }
}